home *** CD-ROM | disk | FTP | other *** search
/ Kit PC World De Ampliacion De Windows 95 / Kit PC World de ampliacion de Windows 95.iso / internet / sweeper / samples / olecon~1 / include / debug.h < prev    next >
C/C++ Source or Header  |  1995-11-25  |  2KB  |  69 lines

  1. //=--------------------------------------------------------------------------=
  2. // Debug.H
  3. //=--------------------------------------------------------------------------=
  4. // Copyright  1995  Microsoft Corporation.  All Rights Reserved.
  5. //
  6. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 
  7. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO 
  8. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 
  9. // PARTICULAR PURPOSE.
  10. //=--------------------------------------------------------------------------=
  11. //
  12. // contains the various macros and the like which are only useful in DEBUG
  13. // builds
  14. //
  15. #ifndef _DEBUG_H_
  16.  
  17. //=---------------------------------------------------------------------------=
  18. // all the things required to handle our ASSERT mechanism
  19. //=---------------------------------------------------------------------------=
  20. //
  21. #if DEBUG
  22.  
  23. // Function Prototypes
  24. //
  25. VOID DisplayAssert(LPSTR pszMsg, LPSTR pszAssert, LPSTR pszFile, UINT line);
  26.  
  27. // Macros
  28. //
  29. // *** Include this macro at the top of any source file using *ASSERT*() macros ***
  30. //
  31. #define SZTHISFILE    static char _szThisFile[] = __FILE__;
  32.  
  33.  
  34. // our versions of the ASSERT and FAIL macros.
  35. //
  36. #define ASSERT(fTest, szMsg)                                \
  37.     if (!(fTest))  {                                        \
  38.         static char szMsgCode[] = szMsg;                    \
  39.         static char szAssert[] = #fTest;                    \
  40.         DisplayAssert(szMsgCode, szAssert, _szThisFile, __LINE__); \
  41.     }
  42.  
  43. #define FAIL(szMsg)                                         \
  44.         { static char szMsgCode[] = szMsg;                    \
  45.         DisplayAssert(szMsgCode, "FAIL", _szThisFile, __LINE__); }
  46.  
  47.  
  48.  
  49. // macro that checks a pointer for validity on input
  50. //
  51. #define CHECK_POINTER(val) if (!(val) || IsBadWritePtr((void *)(val), sizeof(void *))) return E_POINTER
  52.  
  53. #else  // DEBUG
  54.  
  55. #define SZTHISFILE
  56. #define ASSERT(fTest, err)
  57. #define FAIL(err)
  58.  
  59. #define CHECK_POINTER(val)
  60. #endif    // DEBUG
  61.  
  62.  
  63.  
  64.  
  65. #define _DEBUG_H_
  66. #endif // _DEBUG_H_
  67.  
  68.  
  69.